package application.ratt.utils;

import java.util.ArrayList;

public class Route {
	private ArrayList<TimeInStation> stations = new ArrayList<TimeInStation>();
	
	public Route(ArrayList<TimeInStation> stations) throws CloneNotSupportedException {
		this.stations = this.deepClone(stations);
	}
	
	public ArrayList<TimeInStation> getStations(){
		return stations;
	}
	
	private ArrayList<TimeInStation> deepClone(ArrayList<TimeInStation> st) throws CloneNotSupportedException{
		ArrayList<TimeInStation> clonedStation = new ArrayList<TimeInStation>();
		for (TimeInStation s: st){
			clonedStation.add(s.clone());
		}
		return clonedStation;
	}
	
	public String getRouteName(){
		String firstStationName = "";
		String lastStationName = "";
		int listSize = 0;
		
		listSize = stations.size();
		firstStationName = stations.get(0).getName();
		lastStationName = stations.get(listSize-1).getName();
		
		return firstStationName + "-" +lastStationName;
	}
	
	public String getRouteLine(){
		int listSize = 0;
		String line = "";
		
		listSize = stations.size();
		line = stations.get(listSize-1).getLineName();
		
		return line;
	}
	
	public String getRouteTime(){
		int duration = 0;
		
		for (TimeInStation s : stations){
			duration += s.getTime();
		}
		
		return Integer.toString(duration) + "min";
	}
}
